//
//  KyImage.m
//  QuickCare
//
//  Created by 唐润欣 on 16/7/13.
//  Copyright © 2016年 lidabiao. All rights reserved.
//

#import "KyImage.h"
#import "WebViewController.h"

@implementation KyImage

- (instancetype)init{
    self = [super init];
    if (self) {
        self.userInteractionEnabled = YES;
        self.multipleTouchEnabled = YES;
        [self addGesture];
    }
    return self;
}

- (void)addGesture {
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageClick)];
    [self addGestureRecognizer:tap];
}

- (void)imageClick{
    
    if (self.index == 0) {
        [self package:@"运动" andURL:@"http://jingyan.baidu.com/article/15622f2455993dfdfcbea521.html"];
    } else if (self.index == 1) {
        [self package:@"饮食" andURL:@"http://jingyan.baidu.com/article/19020a0afc5829529d2842fa.html"];
    } else if (self.index == 2) {
        [self package:@"睡眠" andURL:@"http://jingyan.baidu.com/article/76a7e409859515fc3b6e153c.html"];
    } else if (self.index == 3) {
        [self package:@"预防疾病" andURL:@"http://baike.baidu.com/link?url=UbKsfjuKySsPyrkMaSHVMkYXn5R4Manv4TuAGOJRogfgpZMeRJpJRv-QXP5iikVua3fyU-YRueBaslHmJtEEIK#6"];
    } else if (self.index == 4) {
        [self package:@"危害" andURL:@"http://jingyan.baidu.com/article/3065b3b6e6c2c8becff8a4d1.html"];
    }
}

- (void)package:(NSString *)title andURL:(NSString *)url {
    
    UIStoryboard *st = [UIStoryboard storyboardWithName:@"Discover" bundle:nil];
    WebViewController *health = [st instantiateViewControllerWithIdentifier:@"WebViewController"];
    
    health.title = title;
    health.url = url;
    [health.navigationController pushViewController:health animated:YES];
    [self.mid skipController:health.title andwith:health.url];
}

@end
